package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties("handler")
public class StrategyDetail extends BaseDomain {
    public static final Integer STATE_RELEASE = 0; //发布
    public static final Integer STATE_TEMP = 1; //草稿

    private String title;

    private Date createTime;

    private Date releaseTime;

    private Integer sequence;

    private String coverUrl;

    private Integer state;

    private StrategyCatalog catalog;

    private StrategyContent strategyContent;

    public Object getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("coverUrl", coverUrl);
        map.put("sequence", sequence);
        map.put("state", state);
        if (catalog != null) {
            map.put("strategyId", catalog.getStrategyId());
            map.put("catalogId", catalog.getId());
        }
        return JSON.toJSONString(map);
    }

    public String getStateName() {
        String str = "发布";
        if (state == STATE_TEMP) {
            str = "草稿";
        }
        return str;
    }


}